<?php

namespace app\index\validate;

use think\Validate;

class Mine extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     * typeof => integer,float,bool,string,array,object,null,resouce
     * @var array
     */	
	protected $rule = [
        'email'=>['email'],
        'username'=>['regex'=> '/^(?=.*[a-zA-Z])[a-zA-Z0-9_-]{6,16}$/'],
        'pwd'=>['regex'=> '/^(?:\d+|[a-zA-Z]+|[!@#$%^&*]+){6,16}$/'],
        'code'=>['regex'=> '/^[a-zA-Z0-9_-]{8}$/'],
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        'email.email' => '邮箱格式不正确',
        'username.regex' => '用户名为6到15位，且必须有字母',
        'pwd.regex' => '密码必须6到15位',
        'code.regex' => '验证码为邮箱接收的8位字符',
    ];

    protected $scene = [
        'login'  =>  ['pwd'],
        'register'  =>  ['email','username','pwd','code'],
    ];
}
